<template>
  <div class="app-container">
    <el-form ref="form" :model="form" :rules="rules" label-width="150px">
      <el-form-item label="用户名" prop="userName">
        <el-input v-model="form.userName" />
      </el-form-item>
      <el-form-item label="用户头像" prop="userImg">
        <img :src="form.userImg" width="10%" height="10%"/>
      </el-form-item>
      <el-form-item label="用户手机号" prop="userPhone">
        <el-input v-model="form.userPhone" />
      </el-form-item>
      <el-form-item label="用户状态" prop="userStatusShow">
        <el-input v-model="form.userStatusShow" disabled/>
      </el-form-item>
      <el-form-item label="注册时间" prop="createTime">
        <el-input v-model="form.createTime" disabled/>
      </el-form-item>
      <el-form-item label="总余额" prop="balanceSum">
        <el-input v-model="form.balanceSum" disabled/>
      </el-form-item>
      <el-form-item label="已提现余额" prop="balanceWithdraw">
        <el-input v-model="form.balanceWithdraw" disabled/>
      </el-form-item>
      <el-form-item label="已使用余额" prop="balanceUse">
        <el-input v-model="form.balanceUse" disabled/>
      </el-form-item>
      <el-form-item label="总金币" prop="goldSum">
        <el-input v-model="form.goldSum" disabled/>
      </el-form-item>
      <el-form-item label="已提现金币" prop="goldWithdraw">
        <el-input v-model="form.goldWithdraw" disabled/>
      </el-form-item>
      <el-form-item label="已兑换金币" prop="goldExchange">
        <el-input v-model="form.goldExchange" disabled/>
      </el-form-item>
      <el-form-item label="总积分" prop="integralSum">
        <el-input v-model="form.integralSum" disabled />
      </el-form-item>
      <el-form-item label="已兑换积分" prop="integralExchange">
        <el-input v-model="form.integralExchange" disabled/>
      </el-form-item>
      <el-form-item label="总交易金" prop="dealGoldMark">
        <el-input v-model="form.dealGoldMark" disabled/>
      </el-form-item>
      <el-form-item label="已兑换交易金" prop="dealGoldExchangeMark">
        <el-input v-model="form.dealGoldExchangeMark" disabled/>
      </el-form-item>
      <el-form-item label="已兑现奖励金" prop="dealGold">
        <el-input v-model="form.dealGold" disabled/>
      </el-form-item>
      <el-form-item label="总奖励金" prop="awardGoldMark">
        <el-input v-model="form.awardGoldMark" disabled/>
      </el-form-item>
      <el-form-item label="已兑换奖励金" prop="awardGoldExchangeMark">
        <el-input v-model="form.awardGoldExchangeMark" disabled/>
      </el-form-item>
      <el-form-item label="已兑现交易金" prop="awardGold">
        <el-input v-model="form.awardGold" disabled/>
      </el-form-item>
      <el-form-item label="上级用户名称" prop="superiorUserName">
        <el-input v-model="form.superiorUserName" disabled/>
      </el-form-item>
      <el-form-item label="是否实名认证" prop="autonymTypeShow" v-if="false">
        <el-input v-model="form.autonymTypeShow" />
      </el-form-item>
      <el-form-item label="身份证号" prop="identityMark">
        <el-input v-model="form.identityMark" />
      </el-form-item>
      <!--<el-form-item label="趣工宝会员编号" prop="memberNo">
        <el-input v-model="form.memberNo" disabled/>
      </el-form-item>-->
      <el-form-item label="银行卡号" prop="bankCardMark" >
        <el-input v-model="form.bankCardMark" />
      </el-form-item>
      <el-form-item label="支行名称" prop="subBranch">
        <el-input v-model="form.subBranch" />
      </el-form-item>
      <el-form-item label="银行卡号正面" prop="bankCardZhengImg">
        <imageUpload v-model="form.bankCardZhengImg"/>
      </el-form-item>
      <el-form-item label="身份证照片正面" prop="identityZhengImg">
        <img :src="form.identityZhengImg" width="10%" height="10%" />
      </el-form-item>
      <el-form-item label="身份证照片反面" prop="identityFanImg">
        <img :src="form.identityFanImg" width="10%" height="10%" />
      </el-form-item>
      <el-form-item label="用户等级" prop="gradeId" v-if="false">
        <el-input v-model="form.gradeCode"  disabled/>
      </el-form-item>
      <el-form-item label="实名认证时间" prop="autonymTime" v-if="false">
        <el-input v-model="form.autonymTime" disabled/>
      </el-form-item>
      <el-form-item style="text-align: center;margin-left:-100px;margin-top:10px;">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="close()">返回</el-button>
      </el-form-item>
      <!--<el-button type="primary" @click="submitForm">确 定</el-button>
      <el-button @click="cancel">取 消</el-button>-->
    </el-form>
  </div>
</template>

<script>
import { listTUserInfo, getTUserInfo, delTUserInfo, addTUserInfo, updateTUserInfo, exportTUserInfo } from "@/api/pos/TUserInfo";

export default {
  name: "userDetaild",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 导出遮罩层
      exportLoading: false,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 用户基础数据表格数据
      TUserInfoList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 表单参数
      form: {},
      // 表单校验
      rules: {
      }
    };
  },
  created() {
    const userId = this.$route.query && this.$route.query.userId;
    console.log(this.$route.query , "--111--", this.$route.query.userId);
    if (userId) {
      console.log(userId)
      getTUserInfo(userId).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "修改用户基础数据";
      });
    }
    //this.getList();
  },
  methods: {
    /** 关闭按钮 */
    close() {
      this.$store.dispatch("tagsView/delView", this.$route);
      this.$router.push({path: "/userManage/TUserInfo", query: {t: Date.now(), pageNum: this.$route.query.pageNum}})
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          updateTUserInfo(this.form).then(response => {
            this.$modal.msgSuccess("修改成功");
            this.open = false;
            this.close();
            //this.open = false;
            //this.getList();
          });
        }
      });
    },
    /** 导出按钮操作 */
    handleExport() {
      const queryParams = this.queryParams;
      this.$modal.confirm('是否确认导出所有用户基础数据数据项？').then(() => {
        this.exportLoading = true;
        return exportTUserInfo(queryParams);
      }).then(response => {
        this.$download.name(response.msg);
        this.exportLoading = false;
      }).catch(() => {});
    }
  }
};
</script>
